/**
 @file sys_usw_dmps_reg.h

 @author  Copyright (C) 2022 Centec Networks Inc.  All rights reserved.

 @date 2022-10-25

 @version v1.0

*/

#ifndef _SYS_USW_DMPS_REG_H
#define _SYS_USW_DMPS_REG_H
#ifdef __cplusplus
extern "C" {
#endif


struct reg_field_info_s
{
    uint8  idx;         // index with field
    uint32 field_id;    // id
    uint32 value;       // config value for field
};
typedef struct reg_field_info_s reg_field_info_t;

#define SET_REG_FIELD_IDX(p_fld_info, p_idx) do {\
    (p_fld_info)->idx = (p_idx);\
} while (0)

#define SET_REG_FIELD_ID(p_fld_info, p_id) do {\
        (p_fld_info)->field_id = (p_id);\
} while (0)

#define SET_REG_FIELD_VALUE(p_fld_info, p_value) do {\
    (p_fld_info)->value = (p_value);\
} while (0)

#define SET_REG_FIELD_INFO(p_fld_info, p_fld_num, p_idx, p_field_id, p_value) do {\
    (p_fld_info + p_fld_num)->idx      = (p_idx);\
    (p_fld_info + p_fld_num)->field_id = (p_field_id);\
    (p_fld_info + p_fld_num)->value    = (p_value);\
    p_fld_num++;\
} while (0)

#define SET_REG_SOURCE_FIELD_INFO(p_fld_info, p_idx, p_field_id) do {\
    (p_fld_info)->idx      = (p_idx);\
    (p_fld_info)->field_id = (p_field_id);\
} while (0)


struct reg_info_para_s
{
    uint32 num;
    reg_field_info_t* p_info;
};
typedef struct reg_info_para_s reg_info_para_t;

#define TEST_WRITE_REGS(reg_info, args...) do { \
    if(NULL == &(reg_info)) return CTC_E_INVALID_PTR; \
    reg_field_info_t test[] = {args}; \
    reg_info.num = sizeof(test)/sizeof(reg_field_info_t); \
    reg_info.p_info = test; \
} while (0)


#ifdef __cplusplus
}
#endif

#endif

